package flash.display
{
	public class Stage extends DisplayObjectContainer
	{
		internal static var stage:Stage;
		public static var font:Font;
		
		protected var _align:Number = 1;
		public function set align(value:Number):void
		{
			_align = value;
			changePropertys["align"] = value;
		}
		public function get align():Number
		{
			return _align;
		}
		protected var _scaleMode:Number = 1;
		public function set scaleMode(value:Number):void
		{
			_scaleMode = value;
			changePropertys["scaleMode"] = value;
		}
		public function get scaleMode():Number
		{
			return _scaleMode;
		}
		public function Stage()
		{
			super();
		}
		public static function init(designWidth:Number,designHeight:Number):Stage
		{
			stage = new Stage();
			stage.setStage(stage);
			var CanvasScaler:Type = importType("UnityEngine.UI.CanvasScaler");
			var canvasScaler:CanvasScaler = stage.renderer.GetComponent(CanvasScaler);
			var Vector2:Type = importType("UnityEngine.Vector2");
			canvasScaler.referenceResolution = new Vector2(designWidth,designHeight);
			return stage;
		}
		protected override function init():void
		{
			var GameObject:Type = importType("UnityEngine.GameObject");
			var Resources:Type = importType("UnityEngine.Resources");
			var renderObject:GameObject = GameObject.Instantiate(Resources.Load("Canvas"));
			renderObject.name = "Stage(" + renderObject.GetInstanceID() + ")";
			var RectTransform:Type = importType("UnityEngine.RectTransform");
			renderer = renderObject.GetComponent(RectTransform);
		}
		protected override function renderWidth():void
		{
			if(changePropertys["width"])
			{
				trace("stage的宽度不能设置");
			}
		}
		protected override function renderHeight():void
		{
			if(changePropertys["height"])
			{
				trace("stage的高度不能设置");
			}
		}
		protected override function onAddedToStage():void
		{
			trace("舞台成功创建");
			super.onAddedToStage();
		}
	}
}